<% content_for :css do %>
  <link rel="stylesheet" type="text/css" href="/css/webuploader.css">
  <style>
    div.webuploader-pick {
      padding: 0 0;
      width: 196px;
      height: 64px;
    }
    p.state {
      position: relative;
      top: -20px;
    }
  </style>
<% end %>
<section class="wrapper">
  <!-- page start-->
  <div class="row">
    <div class="col-lg-12">
      <section class="panel">
        <header class="panel-heading">
          修 改
        </header>
        <div class="panel-body">
          <form class="form-horizontal adminex-form" >
            <!--dom结构部分-->
            <p>温馨提示,请上传宽:高为3:1的规格</p>
            <div class="form-group">
              <label class="col-sm-2 col-sm-2 control-label"><i class="bi_tian">*&nbsp</i>上传图片</label>
              <div class="col-sm-10" >
                <div id="upload_pic" title="点击上传">
                  <img src="/uploads/societies/<%= @slider.random_name %>" style="width: 196px;height: 64px;" alt="点击上传">
                  <p class="state"></p>
                  <input type="text" name="random_name" value="<%= @slider.random_name %>" hidden>
                </div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 col-sm-2 control-label"><i class="bi_tian">*&nbsp</i>图片链接</label>
              <div class="col-sm-10">
                <input type="text" name="href" value="<%= @slider.href %>" class="form-control" placeholder="请输入连接">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 col-sm-2 control-label"><i class="bi_tian">*&nbsp</i>排序</label>
              <div class="col-sm-10">
                <input type="number" name="sort" value="<%= @slider.sort %>" class="form-control" placeholder="请输入数字">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 col-sm-2 control-label"><i class="bi_tian">*&nbsp</i>状态</label>
              <div class="col-sm-10">
                <select class="form-control" name="status">
                  <option value="1">可用</option>
                  <option value="2" <%= @slider.status == 2 ? 'selected' : '' %>>停用</option>
                </select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 col-sm-2 control-label"></label>
              <div class="col-sm-10">
                <button type="button" class="btn btn-primary" id="submit_data" data-url="/admin/sliders/<%= @slider.id %>">提交</button>
              </div>
            </div>
          </form>
        </div>
      </section>
    </div>
  </div>
</section>
<% content_for :js do %>
  <script type="text/javascript" src="/js/webuploader.js"></script>
  <script type="text/javascript" src="/js/upload_pic.js"></script>
  <script type="text/javascript" charset="utf-8">
      $('#submit_data').click(function () {
          var _this = $(this);
          var url = _this.attr('data-url');
          var data = {};
          data['random_name'] = $('input[name=random_name]').val();
          data['href'] = $('input[name=href]').val();
          data['sort'] = $('input[name=sort]').val();
          data['status'] = $('select[name=status]').val();
          doRequest(_this,url,'PUT',data);
      });
  </script>
<% end %>